<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<html>
<head>
    <meta charset="utf-8">
    <title>（事务审批）学生岗位申请 - 学生申请审批表</title>
    <link rel="stylesheet" href="../../dist/css/layui.css">
    <script src="../../dist/layui.js"></script>
    <script src="../../dist/jquery-1_8_3.js"></script>
</head>
<body>
<form class="layui-form">
    <div class="layui-form-item" style="width: 300px">
        <div class="layui-input-block">
            <label>
                <!-- 传入的student_work_application的id -->
                <input type="text" name="id" value='${param.id}' hidden>
            </label>
        </div>
    </div>
<!--选择工作时间-->
    <div class="layui-form-item" style="width: 30%">
        <label class="layui-form-label">选择星期：</label>
        <div class="layui-input-block">
            <select name="date" id="date">
            <option value="">请选择星期</option>
            <option value="MON">周一</option>
            <option value="TUE">周二</option>
            <option value="WED">周三</option>
            <option value="THU">周四</option>
            <option value="FRI">周五</option>
            <option value="SAT">周六</option>
            <option value="SUN">周日</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">时间范围：</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="time" placeholder=" - ">
        </div>
        <div class="layui-form-item layui-form-text" style="padding-left: 5%; padding-top: 2%">
            <button type="button" class="layui-btn layui-btn-radius" id="chooseTime">选择</button>
            <button type="button" class="layui-btn layui-btn-radius" id="resetTime">清空</button>
        </div>
    </div>


    <!-- 时间 -->
    <div class="layui-form-item" style="width: 40%">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">工作时间：</label>
            <div class="layui-input-block">
                <label>
                    <textarea name="workTime" id="workTime" class="layui-textarea" lay-verify="required"></textarea>
                </label>
            </div>
        </div>
    </div>
    <!-- 管理员意见 -->
    <div class="layui-form-item" style="width: 70%">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">意见：</label>
            <div class="layui-input-block">
                <label>
                    <textarea name="advice" placeholder="请输入内容" class="layui-textarea" lay-verify="required"></textarea>
                </label>
            </div>
        </div>
    </div>

    <!-- 操作，单选框 -->
    <div class="layui-form-item">
        <label class="layui-form-label">操作：</label>
        <div class="layui-input-block">
            <input type="radio" name="operation" value="1" title="批准" checked>
            <input type="radio" name="operation" value="-1" title="拒绝">
        </div>
    </div>

        <!-- 提交 -->
    <div style="margin-top: 30px">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal layui-block" lay-submit hidden="">提交</button>
        </div>
    </div>
</form>

<script>
    layui.use(['layer', 'form'], function(){
        var layer = layui.layer
            ,form = layui.form
            ,$ = layui.jquery;

        form.on('submit()',function(data){

            $.ajax({
                url:'/admin/handleStudentWorkApplication',
                async: false,
                type:'post',
                data:data.field,
                // 是否使用传统的方式浅层序列化,若有数组参数或对象参数需要设置true
                traditional: true,
                dataType:'JSON',
                success:function(result){
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    // 关闭父级弹出层
                    parent.layer.close(index);
                    parent.parent.layer.msg("已处理！",{icon:1,time:1000});
                    // 刷新父页面
                    parent.location.reload();
                }
            });
            return false;//组织表单默认提交并跳转
        });
    });

    layui.use('laydate', function() {
        var laydate = layui.laydate;
        //时间范围
        laydate.render({
            elem: '#time'
            , type: 'time'
            , format: 'HH:mm'
            , value: '06:00 - 18:00'
            , range: true
        });
    });
    var count = 0;
    var tar = '';
    // 选择时间
    $('#chooseTime').on('click', function () {
        var choiceTime = $('#date').val() + ':' + $('#time').val();
        if (count !== 0) {
            tar += ',';
        }
        count++;
        tar += choiceTime;
        $('#workTime').val(tar);
    });
    $('#resetTime').on('click', function () {
        tar = '';
        count = 0;
        $('#workTime').val('');
    })
</script>
</body>
</html>